<?php
class Task_Linkcheck{

	public function __construct(){
		ignore_user_abort();
		set_time_limit(0);
		$this->interval=5;
		}
		
	public function start(){
		Zend_Loader::loadclass('plmlink');
		Zend_Loader::loadClass('Mivec_Http_Socket');
		$plmlink=new plmlink();
		$count=count($plmlink->fetchAll('link_isinfo is null '));
		while($count){
		$data=$plmlink->fetchRow('link_isinfo is null ');
		$key=$data['link_address'];
		$id=$data['link_id'];
		$_client = new Mivec_Http_Socket($key);
		$_status=$_client->request()->getStatus();
					if($_status=='404'){
					$info=array(
							'link_isexist' 		=> 0,
							'link_isinfo'		=> 1,					
							'link_lastupdate'	=> date('y-m-d H:i:s')
							);
					}
					if($_status=='200'){
					$info=array(
							'link_isexist' 		=> 1,
							'link_isinfo'		=> 1,					
							'link_lastupdate'	=> date('y-m-d H:i:s')
							);
					}
		$plmlink->update($info,'link_id='.$id);
		$count=count($plmlink->fetchAll('link_isinfo is null '));	
		sleep($this->interval);
		};		
		ignore_user_abort(false);
		}
}